// 春季
const springDiet = {
  low: [
    "吃韭菜炒鸡蛋，温补阳气",
    "喝红枣枸杞粥，养血安神",
    "吃春笋炒肉丝，清热化痰",
    "食用菠菜猪肝汤，补肝明目",
    "吃香椿炒蛋，健脾开胃",
  ],
  medium: [
    "吃草莓，富含维生素 C",
    "喝菊花茶，清肝明目",
    "吃凉拌莴笋，清热利尿",
    "食用荠菜馄饨，营养丰富",
    "吃樱桃，补中益气",
  ],
  high: [
    "吃绿豆汤，清热解毒",
    "喝酸梅汤，生津止渴",
    "吃凉拌黄瓜，清爽可口",
    "食用番茄炒蛋，酸甜开胃",
    "吃西瓜翠衣汤，清热解暑",
  ],
};

const springExercise = {
  low: [
    "室内瑜伽，放松身心",
    "健身操，增强体质",
    "打太极拳，调和气血",
    "跳绳，简单高效",
    "做普拉提，塑造身形",
  ],
  medium: [
    "户外慢跑，享受春光",
    "骑自行车，亲近自然",
    "放风筝，活动筋骨",
    "打羽毛球，锻炼身体协调性",
    "登山，感受春天的气息",
  ],
  high: [
    "游泳，消暑健身",
    "室内动感单车，高效燃脂",
    "打乒乓球，锻炼反应能力",
    "做水上运动，如皮划艇",
    "在阴凉处散步，舒缓心情",
  ],
};

// 夏季
const summerDiet = {
  low: [
    "吃山药红枣粥，健脾益胃",
    "喝热姜茶，驱寒保暖",
    "吃红烧排骨，补充营养",
    "食用南瓜粥，滋养脾胃",
    "吃羊肉汤，暖中补虚",
  ],
  medium: [
    "吃凉拌苦瓜，清热降火",
    "喝绿豆薏仁汤，祛湿解暑",
    "吃凉拌西红柿，生津止渴",
    "食用冬瓜海带汤，清热利水",
    "吃西瓜，消暑解渴",
  ],
  high: [
    "吃凉拌黄瓜，清热解暑",
    "喝酸梅汤，生津止渴",
    "吃凉拌木耳，凉血止血",
    "食用绿豆沙冰，消暑降温",
    "吃椰子水，补充水分",
  ],
};

const summerExercise = {
  low: [
    "室内健身操，保持活力",
    "力量训练，如哑铃练习",
    "跳有氧舞蹈，提高心率",
    "做俯卧撑，增强上肢力量",
    "仰卧起坐，锻炼腹部肌肉",
  ],
  medium: [
    "户外慢跑，享受凉爽",
    "骑自行车，感受微风",
    "打网球，锻炼身体协调性",
    "公园散步，放松身心",
    "登山，呼吸新鲜空气",
  ],
  high: [
    "游泳，消暑又健身",
    "室内瑜伽，放松身心",
    "打乒乓球，锻炼反应能力",
    "做水上瑜伽，舒缓压力",
    "在空调房里做拉伸运动",
  ],
};

// 秋季
const autumnDiet = {
  low: [
    "吃萝卜炖排骨，润肺生津",
    "喝银耳莲子羹，滋阴润燥",
    "吃栗子烧鸡，补肾强筋",
    "食用芝麻糊，滋养肝肾",
    "吃羊肉煲，暖身驱寒",
  ],
  medium: [
    "吃梨，润肺止咳",
    "喝蜂蜜柚子茶，理气化痰",
    "吃凉拌莲藕，清热凉血",
    "食用石榴，抗氧化",
    "吃百合粥，养心安神",
  ],
  high: [
    "吃绿豆汤，清热解毒",
    "喝菊花茶，清肝明目",
    "吃凉拌苦瓜，清热降火",
    "食用西红柿蛋汤，酸甜开胃",
    "吃西瓜翠衣汤，清热解暑",
  ],
};

const autumnExercise = {
  low: [
    "室内健身操，增强体质",
    "打太极拳，调和气血",
    "跳有氧舞蹈，提高心率",
    "做俯卧撑，增强上肢力量",
    "仰卧起坐，锻炼腹部肌肉",
  ],
  medium: [
    "户外慢跑，欣赏秋景",
    "骑自行车，感受秋风",
    "打羽毛球，锻炼身体协调性",
    "公园散步，放松身心",
    "登山，感受秋天的色彩",
  ],
  high: [
    "游泳，消暑健身",
    "室内瑜伽，放松身心",
    "打乒乓球，锻炼反应能力",
    "做水上运动，如划船",
    "在阴凉处散步，舒缓心情",
  ],
};

// 冬季
const winterDiet = {
  low: [
    "吃羊肉火锅，暖身驱寒",
    "喝热巧克力，补充能量",
    "吃当归生姜羊肉汤，补血养颜",
    "食用牛肉炖萝卜，健脾开胃",
    "吃火锅丸子汤，温暖肠胃",
  ],
  medium: [
    "吃饺子，营养丰富",
    "喝红枣桂圆汤，补气养血",
    "吃红烧鱼，补充蛋白质",
    "食用白菜豆腐汤，清淡可口",
    "吃烤红薯，香甜暖身",
  ],
  high: [
    "吃绿豆汤，清热解毒",
    "喝菊花茶，清肝明目",
    "吃凉拌黄瓜，清热解暑",
    "食用番茄蛋汤，酸甜开胃",
    "吃西瓜翠衣汤，清热解暑",
  ],
};

const winterExercise = {
  low: [
    "室内瑜伽，温暖身心",
    "健身操，增强体质",
    "力量训练，如杠铃练习",
    "跳有氧舞蹈，提高心率",
    "使用健身器材锻炼",
  ],
  medium: [
    "户外慢跑，呼吸冷空气",
    "骑自行车，享受冬日阳光",
    "打羽毛球，锻炼身体协调性",
    "公园散步，放松身心",
    "登山，挑战自我",
  ],
  high: [
    "游泳，消暑健身",
    "室内动感单车，高效燃脂",
    "打乒乓球，锻炼反应能力",
    "做水上运动，如水上排球",
    "在空调房里做拉伸运动",
  ],
};

// 随机选择数组中的三个元素
function getRandomRecommendations(arr) {
  const shuffled = arr.sort(() => 0.5 - Math.random());
  return shuffled.slice(0, 3);
}

// 根据温度和季节生成推荐
export function getRecommendations(season, temperature) {
  let dietArr;
  let exerciseArr;

  let temperatureRange;
  if (temperature < 10) {
    temperatureRange = "low";
  } else if (temperature >= 10 && temperature < 25) {
    temperatureRange = "medium";
  } else {
    temperatureRange = "high";
  }

  switch (season) {
    case "春季":
      dietArr = springDiet[temperatureRange];
      exerciseArr = springExercise[temperatureRange];
      break;
    case "夏季":
      dietArr = summerDiet[temperatureRange];
      exerciseArr = summerExercise[temperatureRange];
      break;
    case "秋季":
      dietArr = autumnDiet[temperatureRange];
      exerciseArr = autumnExercise[temperatureRange];
      break;
    case "冬季":
      dietArr = winterDiet[temperatureRange];
      exerciseArr = winterExercise[temperatureRange];
      break;
    default:
      dietArr = [];
      exerciseArr = [];
  }

  const dietRecommendations = getRandomRecommendations(dietArr);
  const exerciseRecommendations = getRandomRecommendations(exerciseArr);

  return {
    diet: dietRecommendations,
    exercise: exerciseRecommendations,
  };
}
